<?php


namespace app\common\model;


class ArticleModel extends CommonModel
{
    protected $name = 'article';

    public function getArticleList($where = [], $field = '*', $whereOr = [])
    {
        $conn = $this->with([])->order(
            [
                'create_time' => 'desc',
            ]
        )->where($where)->append(
            []
        )->field($field);
        foreach ($whereOr as $item) {
            $conn->whereOr($item);
        }
        return $conn->select();
    }

    public function getArticleListPaginate($where = [], $field = '*', $whereOr = [], $page = 1, $limit = 10)
    {
        $conn = $this->with([])->order(
            [
                'create_time' => 'desc',
            ]
        )->where($where)->append(
            []
        )->field($field);
        foreach ($whereOr as $item) {
            $conn->whereOr($item);
        }
        return $conn->field($field)->paginate(
            [
                'page'      => $page,
                'list_rows' => $limit,
            ]
        );
    }

    public function getArticle($where = [], $field = '*', $whereOr = [])
    {

    }
}